﻿namespace UnitBox {
	public class SwapNextInstanceConfiguration<T> {

		#region class fields

		private static volatile SwapNextInstanceConfiguration<T> _singletonInstance;

		#endregion


		#region constructors

		private SwapNextInstanceConfiguration() {
			// hidden singleton constructor
		}

		#endregion


		#region properties

		internal static SwapNextInstanceConfiguration<T> Instance {
			get {
				if( _singletonInstance == null ) {
					lock( typeof(SwapNextInstanceConfiguration<T>) ) {
						if( _singletonInstance == null )
							_singletonInstance = new SwapNextInstanceConfiguration<T>();
					}
				}
				return _singletonInstance;
			}
		}


		#endregion


		#region public methods

		/// <summary>
		/// Specifies the object with which to swap the next instance of <see cref="T"/> with.
		/// </summary>
		/// <param name="instanceToSwap"></param>
		public VerifySwapConfiguration<T> With( T instanceToSwap ) {
			// configure swap queue to swap the next instance of the given type
			SwapQueue.SwapNextInstanceWith( instanceToSwap );

			return VerifySwapConfiguration<T>.Instance;
		}

		#endregion

	}
}